﻿using HROReporting.Infrastructure.Authentication;
using HROReporting.Infrastructure.Querying;
using HROReporting.Infrastructure.UnitOfWork;
using HROReporting.Model.Studenten;
using NHibernate;
using NHibernate.Criterion;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HROReporting.Repository.NHibernate.Repositories
{
    /*
    public class UserRepository : Repository<User, int> //, IUserRepository
    {
        public UserRepository(IUnitOfWork uow)
            : base(uow)
        {
        }

        public User FindBy(string email)
        {
            ICriteria criteriaQuery = SessionFactory.GetCurrentSession()
                .CreateCriteria(typeof(User))
                .Add(Expression.Eq(PropertyNameHelper
                .ResolvePropertyName<User>
                (s => s.Email), email));

            IList<User> users = criteriaQuery.List<User>();

            User user = users.FirstOrDefault();
            return user;
        }

        public User GetUserByAuthenticationToken(string authenticationToken)
        {
            ICriteria criteriaQuery = SessionFactory.GetCurrentSession()
                .CreateCriteria(typeof(User))
                .Add(Expression.Eq(PropertyNameHelper
                .ResolvePropertyName<User>
                (d => d.Email), authenticationToken));

            IList<User> users = criteriaQuery.List<User>();
            User user = users.FirstOrDefault();

            return user;
        }

        public Reservering GetReserveringById(int id)
        {
            throw new NotImplementedException();
        }

    }*/
}
